import { defineStore } from 'pinia'
import type { userBanner, userData } from '@/types/index'

import { http } from '@/utils/request'

const useHomeStore = defineStore({
  // 唯一标识
  id: "home",
  // 持久化插件 - 默认存所有模块数据
  // persist: true,
  // 持久化插件 - 进阶用法
  persist: {
    // 修改存储时的键名称
    key: "list-home",
    // 按需存储分类数据
    paths: ["banner",'list'],
  },
  state() {
    return {
      list: {} as userData,
      banner: [] as userBanner[]
    }
  },
  getters: {

  },
  actions: {
    async userDate() {
      const res = await http<userData>('get', 'index')
      console.log(res.data)
      this.list = res.data.data;
      this.banner = res.data.data.banner;
    }
  }
})
export default useHomeStore